
//
//  YuYueOrderYuYueMessageView.m
//  FD
//
//  Created by xiaofang wang on 2018/11/23.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "YuYueOrderYuYueMessageView.h"
#define k15 15.0
//h 160 + 2 + 5=  167
@interface YuYueOrderYuYueMessageView()

/**1.预约信息div1*/
@property (nonatomic, strong) UIView *div1;
/**1-1预约信息lb*/
@property (nonatomic, strong) UILabel *yuyueMsgLb;

/**联系人div2*/
@property (nonatomic, strong) UIView *div2;

/**电话div3*/
@property (nonatomic, strong) UIView *div3;

/**4餐品信息div4*/
@property (nonatomic, strong) UIView *div4;
/**4-1餐品信息lb*/
@property (nonatomic, strong) UILabel *canpinMsgLb;

/**1-11线*/
@property (nonatomic, strong) UIView *lightGrayLineView;

@end

@implementation YuYueOrderYuYueMessageView


#pragma mark - 一 init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        self.backgroundColor = kMainLightGrayColor;
    }
    return self;
}
- (void)setupView {
    [self addSubview:self.div1];
    [self addSubview:self.div2];
    [self addSubview:self.div3];
    [self addSubview:self.div4];
    
    [self.div1 addSubview:self.yuyueMsgLb];
    [self.div2 addSubview:self.lianxiRenLb];
    [self.div3 addSubview:self.phoneLb];
    [self.div4 addSubview:self.canpinMsgLb];
    [self.div4 addSubview:self.lightGrayLineView];
}

#pragma mark - 二 getter
//!!!!: div1
- (UIView *)div1 {
    if (!_div1) {
        _div1 = [UIView new];
        _div1.backgroundColor = [UIColor whiteColor];
    }
    return _div1;
}
- (UILabel *)yuyueMsgLb {
    if (!_yuyueMsgLb) {
        _yuyueMsgLb = [UILabel new];
        //国际化
        NSString *ysmsgStr = NSLocalizedString(Home_YuYueMsg, @"预约信息");
        _yuyueMsgLb.text = ysmsgStr;
    }
    return _yuyueMsgLb;
}

//!!!!: div2
- (UIView *)div2 {
    if (!_div2) {
        _div2 = [UIView new];
        _div2.backgroundColor = [UIColor whiteColor];
    }
    return _div2;
}

- (UILabel *)lianxiRenLb {
    if (!_lianxiRenLb) {
        _lianxiRenLb = [UILabel new];
        
        NSString *lxrStr = NSLocalizedString(Home_contacts, @"联系人");
        _lianxiRenLb.text = lxrStr;
    }
    return _lianxiRenLb;
}

//!!!!: div3
- (UIView *)div3 {
    if (!_div3) {
        _div3 = [UIView new];
        _div3.backgroundColor = [UIColor whiteColor];
    }
    return _div3;
}
- (UILabel *)phoneLb {
    if (!_phoneLb) {
        _phoneLb = [UILabel new];
        //国际化
        NSString *phoneStr = NSLocalizedString(Order_ContactPhone, @"联系电话:");
        _phoneLb.text = phoneStr;
    }
    return _phoneLb;
}


//!!!!: div4
- (UIView *)div4 {
    if (!_div4) {
        _div4 = [UIView new];
        _div4.backgroundColor = [UIColor whiteColor];
    }
    return _div4;
}
- (UILabel *)canpinMsgLb {
    if (!_canpinMsgLb) {
        _canpinMsgLb = [UILabel  new];
        
        //国际化
        NSString *cpmsgStr = NSLocalizedString(Home_CanPinMsg, @"餐品信息");
        _canpinMsgLb.text = cpmsgStr;
    }
    return _canpinMsgLb;
}

- (UIView *)lightGrayLineView {
    if (!_lightGrayLineView) {
        _lightGrayLineView = [UIView new];
        _lightGrayLineView.backgroundColor = kMainLightGrayColor;
    }
    return _lightGrayLineView;
}


#pragma mark - 三 layout
//h 160 + 2 + 5=  167
- (void)layoutSubviews {
    [super layoutSubviews];
    
    //h:40
    [self.div1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self);
        make.height.mas_equalTo(40);
    }];
    //h:40 + 1
    [self.div2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div1.mas_bottom).offset(1);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(40);
    }];
    
    //h:40 + 1
    [self.div3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div2.mas_bottom).offset(1);
        make.height.mas_equalTo(40);
    }];
    
    //h:40 + 5
    [self.div4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div3.mas_bottom).offset(5);
        make.height.mas_equalTo(40);
    }];
    
    
    [self layoutDiv1];
    [self layoutDiv2];
    [self layoutDiv3];
    [self layoutDiv4];
}


//!!!!: div1layout1
- (void)layoutDiv1 {
    [self.yuyueMsgLb mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.mas_equalTo(CGSizeMake(120, 30));
        make.height.mas_equalTo(30);
        make.width.mas_greaterThanOrEqualTo(120); //2019-2-23宽度自适应
        make.centerY.equalTo(self.div1.mas_centerY);
        make.left.equalTo(self.div1.mas_left).offset(k15);
    }];
}

//!!!!: div2layout2
- (void)layoutDiv2 {
    [self.lianxiRenLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div2.mas_left).offset(k15);
        make.top.bottom.equalTo(self.div2);
        make.right.equalTo(self.div2.mas_right).offset(-10);
    }];
}

//!!!!: div3layout34
- (void)layoutDiv3 {
    [self.phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div3.mas_left).offset(k15);
        make.top.bottom.equalTo(self.div3);
        make.right.equalTo(self.div3.mas_right).offset(-10);
    }];
}

//!!!!: div4layout4
- (void)layoutDiv4 {
    [self.canpinMsgLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div4.mas_left).offset(k15);
        make.size.mas_equalTo(CGSizeMake(120, 30));
        make.centerY.equalTo(self.div4);
    }];
    
    //线
    [self.lightGrayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div4.mas_left).offset(k15);
        make.right.equalTo(self.div4.mas_right).offset(-k15);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.div4);
    }];
}

@end
